<?php

/**
 * _Order form base class.
 *
 * @method _Order getObject() Returns the current form's model object
 *
 * @package    Porba
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class Base_OrderForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'contact_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'add_empty' => false)),
      'c_order_number' => new sfWidgetFormInputText(),
      'status'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('StatusOrder'), 'add_empty' => false)),
      'date_recieved'  => new sfWidgetFormDate(),
      'date_ready'     => new sfWidgetFormDate(),
      'date_completed' => new sfWidgetFormDate(),
      'date_due'       => new sfWidgetFormDate(),
      'ship_lastname'  => new sfWidgetFormInputText(),
      'ship_firstname' => new sfWidgetFormInputText(),
      'ship_address'   => new sfWidgetFormInputText(),
      'ship_zipcode'   => new sfWidgetFormInputText(),
      'ship_city'      => new sfWidgetFormInputText(),
      'ship_country'   => new sfWidgetFormInputText(),
      'category_name'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryOrder'), 'add_empty' => false)),
      'total_price'    => new sfWidgetFormInputText(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'contact_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'))),
      'c_order_number' => new sfValidatorInteger(array('required' => false)),
      'status'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('StatusOrder'))),
      'date_recieved'  => new sfValidatorDate(),
      'date_ready'     => new sfValidatorDate(array('required' => false)),
      'date_completed' => new sfValidatorDate(array('required' => false)),
      'date_due'       => new sfValidatorDate(),
      'ship_lastname'  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ship_firstname' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ship_address'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ship_zipcode'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ship_city'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ship_country'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'category_name'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryOrder'))),
      'total_price'    => new sfValidatorNumber(),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('_order[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return '_Order';
  }

}
